<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>优视雅|找回密码</title>
        <meta content="优视雅" name="author">
        <meta content="优视雅" name="Copyright">
        <meta http-equiv="Cache-Control" content="no-siteapp" />
        <meta content="优视雅" name="description">
        <meta content="优视雅" name="keywords">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="viewport" content="width=device-width,height=device-height,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
        <!--<link rel="stylesheet" type="text/css" href="css/public.css">-->
        <link rel="stylesheet" type="text/css" href="__INDEX__/css/register.css">
        <link rel="shortcut icon" href="__INDEX__/images/favorite.ico">
        <script src="__INDEX__/js/jquery-1.9.1.min.js"></script>
    </head>
    <body>
          <div class="g-wrap">
            <div class="g-header">
                <a href="{:url('Index/index')}" class="logo"><img src="{$logo}"/></a>
                <div class="r"></div>
            </div>
            <div class="g-content" style="background: url(__INDEX__/images/loginBg.jpg) no-repeat;height: 600px;">
                <div class="login" >
                <div class="form-top-tip">
                    <span id="J_head_tip">找回密码</span><a class="" href="{:url('Login/index')}">去登录</a>
                </div>
                <div class="form">
                    <form action="" method="post">
                        <div class="group">
                            <label for="name">用户名</label>   
                            <input type="text" id="account" name="account" placeholder="账号" value="{$account ? $account : ''}" {$account? 'disabled' : ''} /><span></span>
                        </div>
                        <div class="group">
                            <label for="tel">新密码</label>    
                            <input type="password" id="pwd" name="pwd" placeholder="新密码" /><span></span>
                        </div>
                        <div class="group">
                            <label for="check">验证码</label>  
                            <input class="check" name="forget_code" id="code" placeholder="验证码"/>
                            <input type="button" class="checkbtn"  id="J_getCode" value="获取验证码"/>
                        </div>
                        
                        <input type="button" id="submitReg"  class="submit" value="确定"/>
                    </form>
                </div>
                </div>
            </div>
          </div>
    <script src="__LAYER__/mobile/layer.js"></script>
    <script src="__LAYER__/layer.js"></script>
    <script>

        $("#J_getCode").click(function(){

            var timer=null,num=60;
            var account= $('#account').val();
            if ( "" == account || !account) {
                layer_alert("请输入账号!");
                return false;
            }
            $.ajax({
                type: 'POST',
                url: '{:url("Login/get_forget_code")}',
                dataType: 'json',
                data: {account: account},
                success: function (data) {
                    if( data.result == 0 ){
                        $("#account").attr("disabled","disabled");
                        layer_alert(data.msg);
                        timer = setInterval(function(){
                            $(".get-code").attr("disabled",true);
                            $(".get-code").text(num+"s"+"重新发送");
                            if(num < 0){
                                $(".get-code").text("获取验证码 ");
                                $(".get-code").removeAttr("disabled");
                                clearInterval(timer);
                            }
                            num--;
                        },1000);
                    }else{
                        layer_alert(data.msg);
                    }
                }
            });
        });


        $("#submitReg").click(function(){

            var account = $("#account").val();
            var forget_code = $("#code").val();
            var pwd = $("#pwd").val();
            if ( "" == forget_code || !forget_code) {
                layer_alert("请输入6位数的手机验证码!");
                return false;
            }
            if ( "" == pwd || !pwd) {
                layer_alert("请输入新的密码!");
                return false;
            }
            $.ajax({
                type: 'POST',
                url: '{:url("Login/forget_pas")}',
                dataType: 'json',
                data: {account: account,forget_code:forget_code,pwd:pwd},
                success: function (data) {
                    if( data.result == 0 ){
                        location.href = '{:url("Index/index")}';
                    }else{
                        layer_alert(data.msg);
                    }
                }
            });
        });


        function layer_alert(src){
            layer.open({
                content: src
                ,style: 'color:#fff;background-color:#da7276; border:none;'
                ,time: 2000 //2秒后自动关闭
            });
        }

    </script>
           <!-- <script>
    //获取验证码倒计时
            $(".checkbtn").click(function(){
                $(this).attr("disabled","disabled")
                    var timer=null,num=60;
                timer=setInterval(function(){
                    num--;
                    if(num<0){
                        $(".checkbtn").val("获取验证码");
                        $(".checkbtn")[0].removeAttribute("disabled");
                    clearInterval(timer);
                }else{
        //          console.log(num);
                    $(".checkbtn").val(num+"s后重新获取");
                }
                },1000)
            })
 </script> -->
    </body>
</html>
